package com.sb.hot.ext.pe;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 刘雄康
 * @version V1.0
 * @copyright 2020 CMB - Powered By 研发一部
 * @date 2021/04/16 22:44
 */
@RestController
public class PeTest {
    @Autowired
    private DependsOnExoticType dependsOnExoticType;

    @GetMapping(value = "/getpe1")
    public Object getpe() {
        return dependsOnExoticType;
        //        BeanFactory factory = new ClassPathXmlApplicationContext("Text.xml");
        //        return factory.getBean("sample", DependsOnExoticType.class);
        //        return "null";
    }

    @InitBinder
    public void initBinder(ServletRequestDataBinder binder) {
        binder.registerCustomEditor(ExoticType.class, new ExoticTypeEditor());
    }

    @GetMapping(value = "/getpe2")
    public Object get(ExoticType exoticType) {
        return exoticType;
    }

    @GetMapping(value = "/getpe3")
    public Object get(DependsOnExoticType dependsOnExoticType) {
        return dependsOnExoticType;
    }
}
